<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 了解 -->
      <!-- 当组件里面，传递自定义属性的时候，如果子组件又没有props进行接收，那么该属性就会直接添加到子组件的根元素上面 -->
      <h2>透传 Attributes</h2>
      <child id="abc" msg="hello" class="box2" @click="fn"></child>
    </div>

    <script src="./Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const Child2 = {
        template: `
          <div>child2组件</div>
        `,
      };

      const Child = {
        props: ["msg"],
        // 禁止属性透传,vue3新增
        inheritAttrs: false,
        // template: `
        //   <div class="box1">child组件</div>
        // `,
        template: `
          <child2></child2>
        `,
        components: {
          Child2,
        },
      };

      createApp({
        data() {
          return {};
        },
        components: {
          Child,
        },
        methods: {
          fn() {
            console.log(123);
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
